package com.nbsaas.boot.cms.rest.resource;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nbsaas.boot.cms.api.apis.ArticleApi;
import com.nbsaas.boot.cms.data.entity.Article;
import com.nbsaas.boot.cms.api.domain.request.ArticleRequest;
import com.nbsaas.boot.cms.api.domain.request.ArticleSearch;
import com.nbsaas.boot.cms.api.domain.response.ArticleResponse;
import com.nbsaas.boot.cms.api.domain.simple.ArticleSimple;
import com.nbsaas.boot.cms.rest.convert.ArticleSimpleConvert;
import com.nbsaas.boot.cms.rest.convert.ArticleEntityConvert;
import com.nbsaas.boot.cms.rest.convert.ArticleResponseConvert;
import com.nbsaas.boot.cms.data.mapper.ArticleMapper;

import com.nbsaas.boot.mp.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.function.Function;

/**
*   业务接口实现
*/
@Transactional
@Service
public class ArticleResource extends BaseResource<Article,ArticleResponse, ArticleSimple, ArticleRequest>  implements ArticleApi {

    @Resource
    private ArticleMapper articleMapper;

    @Override
    public BaseMapper<Article> getMapper() {
        return articleMapper;
    }

    @Override
    public Function<Article, ArticleSimple> getConvertSimple() {
        return new ArticleSimpleConvert();
    }

    @Override
    public Function<ArticleRequest, Article> getConvertForm() {
        return new ArticleEntityConvert();
    }

    @Override
    public Function<Article, ArticleResponse> getConvertResponse() {
        return new ArticleResponseConvert();
    }




}


